package com.biz.primus.commodity.vo.backend;

import com.biz.primus.base.exception.utils.AssertUtils;
import com.biz.primus.commodity.exception.CommodityExceptionType;
import com.biz.primus.commodity.interfaces.Validate;
import lombok.Data;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.List;

/**
 * @author jiangnan
 * @Description: TODO
 * @create 2017-10-11-上午11:48
 */
@Data
public class GroupProductCreateVo implements Serializable,Validate {

    /**
     * 组合商品的商品编码
     */
    @NotNull
    private String productCode;

    /**
     * 子商品商品编码
     */
    @Size(min = 1,message = "组合商品子商品不能为空")
    private List<String> itemProductCodes;

    /**
     * 对应子商品的数量
     */
    @Size(min = 1,message = "组合商品子商品的数量不能为空")
    private List<Integer> itemQuantity;

    /**
     * 对应子商品的价格系数
     */
    @Size(min = 1,message = "子商品的价格系数不能为空")
    private List<Double> itemPriceFactor;


    @Override
    public void validate() {
        AssertUtils.isTrue(itemProductCodes.size() == itemQuantity.size()&& itemQuantity.size()== itemPriceFactor.size(),
                CommodityExceptionType.REQUEST_PARAM_EXCEPTION,"子商品参数无法对应");
    }
}
